package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WorkAwardWinners;
import com.ruoyi.system.service.IWorkAwardWinnersService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 获奖完成人Controller
 * 
 * @author ruoyi
 * @date 2024-07-03
 */
@RestController
@RequestMapping("/work/awardWinners")
public class WorkAwardWinnersController extends BaseController
{
    @Autowired
    private IWorkAwardWinnersService workAwardWinnersService;

    /**
     * 查询获奖完成人列表
     */
    @PreAuthorize("@ss.hasPermi('work:awardWinners:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkAwardWinners workAwardWinners)
    {
        startPage();
        List<WorkAwardWinners> list = workAwardWinnersService.selectWorkAwardWinnersList(workAwardWinners);
        return getDataTable(list);
    }

    /**
     * 导出获奖完成人列表
     */
    @PreAuthorize("@ss.hasPermi('work:awardWinners:export')")
    @Log(title = "获奖完成人", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkAwardWinners workAwardWinners)
    {
        List<WorkAwardWinners> list = workAwardWinnersService.selectWorkAwardWinnersList(workAwardWinners);
        ExcelUtil<WorkAwardWinners> util = new ExcelUtil<WorkAwardWinners>(WorkAwardWinners.class);
        util.exportExcel(response, list, "获奖完成人数据");
    }

    /**
     * 获取获奖完成人详细信息
     */
    @PreAuthorize("@ss.hasPermi('work:awardWinners:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(workAwardWinnersService.selectWorkAwardWinnersById(id));
    }

    /**
     * 新增获奖完成人
     */
    @PreAuthorize("@ss.hasPermi('work:awardWinners:add')")
    @Log(title = "获奖完成人", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkAwardWinners workAwardWinners)
    {
        return toAjax(workAwardWinnersService.insertWorkAwardWinners(workAwardWinners));
    }

    /**
     * 修改获奖完成人
     */
    @PreAuthorize("@ss.hasPermi('work:awardWinners:edit')")
    @Log(title = "获奖完成人", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkAwardWinners workAwardWinners)
    {
        return toAjax(workAwardWinnersService.updateWorkAwardWinners(workAwardWinners));
    }

    /**
     * 删除获奖完成人
     */
    @PreAuthorize("@ss.hasPermi('work:awardWinners:remove')")
    @Log(title = "获奖完成人", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(workAwardWinnersService.deleteWorkAwardWinnersByIds(ids));
    }
}
